home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 72 / IOPROG_72.ISO / soft / c++ / NCTDiscWriter2.exe / {app} / MS C# 7.0 Samples / TestCSDataCDWriter / frmDiskInfo.cs < prev    next >
Encoding:
Text File  |  2003-03-04  |  9.7 KB  |  315 lines

  1. using System;
  2. using System.Drawing;
  3. using System.Collections;
  4. using System.ComponentModel;
  5. using System.Windows.Forms;
  6.  
  7. namespace DiskWriter
  8. {
  9.     /// <summary>
  10.     /// Summary description for frmDiskInfo.
  11.     /// </summary>
  12.     public class frmDiskInfo : System.Windows.Forms.Form
  13.     {
  14.         internal System.Windows.Forms.GroupBox GroupBox1;
  15.         internal System.Windows.Forms.Label cdEstUsedSpaceLbl;
  16.         internal System.Windows.Forms.Label Label5;
  17.         internal System.Windows.Forms.Label cdUsedSpaceLbl;
  18.         internal System.Windows.Forms.Label cdStatusLbl;
  19.         internal System.Windows.Forms.Label cdTypeLbl;
  20.         internal System.Windows.Forms.Label Label3;
  21.         internal System.Windows.Forms.Label Label2;
  22.         internal System.Windows.Forms.Label Label1;
  23.         internal System.Windows.Forms.Button RefreshBtn;
  24.         internal System.Windows.Forms.Button EjectBtn;
  25.         internal System.Windows.Forms.Button OKBtn;
  26.         /// <summary>
  27.         /// Required designer variable.
  28.         /// </summary>
  29.         private System.ComponentModel.Container components = null;
  30.  
  31.         public Form1 frm;
  32.  
  33.         public frmDiskInfo()
  34.         {
  35.             //
  36.             // Required for Windows Form Designer support
  37.             //
  38.             InitializeComponent();
  39.  
  40.             //
  41.             // TODO: Add any constructor code after InitializeComponent call
  42.             //
  43.         }
  44.  
  45.         /// <summary>
  46.         /// Clean up any resources being used.
  47.         /// </summary>
  48.         protected override void Dispose( bool disposing )
  49.         {
  50.             if( disposing )
  51.             {
  52.                 if(components != null)
  53.                 {
  54.                     components.Dispose();
  55.                 }
  56.             }
  57.             base.Dispose( disposing );
  58.         }
  59.  
  60.         #region Windows Form Designer generated code
  61.         /// <summary>
  62.         /// Required method for Designer support - do not modify
  63.         /// the contents of this method with the code editor.
  64.         /// </summary>
  65.         private void InitializeComponent()
  66.         {
  67.             this.GroupBox1 = new System.Windows.Forms.GroupBox();
  68.             this.cdEstUsedSpaceLbl = new System.Windows.Forms.Label();
  69.             this.Label5 = new System.Windows.Forms.Label();
  70.             this.cdUsedSpaceLbl = new System.Windows.Forms.Label();
  71.             this.cdStatusLbl = new System.Windows.Forms.Label();
  72.             this.cdTypeLbl = new System.Windows.Forms.Label();
  73.             this.Label3 = new System.Windows.Forms.Label();
  74.             this.Label2 = new System.Windows.Forms.Label();
  75.             this.Label1 = new System.Windows.Forms.Label();
  76.             this.RefreshBtn = new System.Windows.Forms.Button();
  77.             this.EjectBtn = new System.Windows.Forms.Button();
  78.             this.OKBtn = new System.Windows.Forms.Button();
  79.             this.GroupBox1.SuspendLayout();
  80.             this.SuspendLayout();
  81.             // 
  82.             // GroupBox1
  83.             // 
  84.             this.GroupBox1.Controls.AddRange(new System.Windows.Forms.Control[] {
  85.                                                                                     this.cdEstUsedSpaceLbl,
  86.                                                                                     this.Label5,
  87.                                                                                     this.cdUsedSpaceLbl,
  88.                                                                                     this.cdStatusLbl,
  89.                                                                                     this.cdTypeLbl,
  90.                                                                                     this.Label3,
  91.                                                                                     this.Label2,
  92.                                                                                     this.Label1});
  93.             this.GroupBox1.Location = new System.Drawing.Point(8, 8);
  94.             this.GroupBox1.Name = "GroupBox1";
  95.             this.GroupBox1.Size = new System.Drawing.Size(337, 126);
  96.             this.GroupBox1.TabIndex = 1;
  97.             this.GroupBox1.TabStop = false;
  98.             this.GroupBox1.Text = "Disc Total";
  99.             // 
  100.             // cdEstUsedSpaceLbl
  101.             // 
  102.             this.cdEstUsedSpaceLbl.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
  103.             this.cdEstUsedSpaceLbl.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
  104.             this.cdEstUsedSpaceLbl.Location = new System.Drawing.Point(134, 97);
  105.             this.cdEstUsedSpaceLbl.Name = "cdEstUsedSpaceLbl";
  106.             this.cdEstUsedSpaceLbl.Size = new System.Drawing.Size(191, 18);
  107.             this.cdEstUsedSpaceLbl.TabIndex = 13;
  108.             this.cdEstUsedSpaceLbl.Text = "0";
  109.             this.cdEstUsedSpaceLbl.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
  110.             // 
  111.             // Label5
  112.             // 
  113.             this.Label5.Location = new System.Drawing.Point(14, 99);
  114.             this.Label5.Name = "Label5";
  115.             this.Label5.Size = new System.Drawing.Size(104, 15);
  116.             this.Label5.TabIndex = 12;
  117.             this.Label5.Text = "Est. Space:";
  118.             // 
  119.             // cdUsedSpaceLbl
  120.             // 
  121.             this.cdUsedSpaceLbl.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
  122.             this.cdUsedSpaceLbl.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
  123.             this.cdUsedSpaceLbl.Location = new System.Drawing.Point(134, 73);
  124.             this.cdUsedSpaceLbl.Name = "cdUsedSpaceLbl";
  125.             this.cdUsedSpaceLbl.Size = new System.Drawing.Size(191, 18);
  126.             this.cdUsedSpaceLbl.TabIndex = 11;
  127.             this.cdUsedSpaceLbl.Text = "0";
  128.             this.cdUsedSpaceLbl.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
  129.             // 
  130.             // cdStatusLbl
  131.             // 
  132.             this.cdStatusLbl.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
  133.             this.cdStatusLbl.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
  134.             this.cdStatusLbl.Location = new System.Drawing.Point(134, 49);
  135.             this.cdStatusLbl.Name = "cdStatusLbl";
  136.             this.cdStatusLbl.Size = new System.Drawing.Size(191, 18);
  137.             this.cdStatusLbl.TabIndex = 10;
  138.             this.cdStatusLbl.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
  139.             // 
  140.             // cdTypeLbl
  141.             // 
  142.             this.cdTypeLbl.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
  143.             this.cdTypeLbl.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
  144.             this.cdTypeLbl.Location = new System.Drawing.Point(134, 26);
  145.             this.cdTypeLbl.Name = "cdTypeLbl";
  146.             this.cdTypeLbl.Size = new System.Drawing.Size(192, 18);
  147.             this.cdTypeLbl.TabIndex = 9;
  148.             this.cdTypeLbl.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
  149.             // 
  150.             // Label3
  151.             // 
  152.             this.Label3.Location = new System.Drawing.Point(14, 76);
  153.             this.Label3.Name = "Label3";
  154.             this.Label3.Size = new System.Drawing.Size(104, 15);
  155.             this.Label3.TabIndex = 8;
  156.             this.Label3.Text = "Used Space:";
  157.             // 
  158.             // Label2
  159.             // 
  160.             this.Label2.Location = new System.Drawing.Point(14, 52);
  161.             this.Label2.Name = "Label2";
  162.             this.Label2.Size = new System.Drawing.Size(104, 15);
  163.             this.Label2.TabIndex = 7;
  164.             this.Label2.Text = "Status:";
  165.             // 
  166.             // Label1
  167.             // 
  168.             this.Label1.Location = new System.Drawing.Point(14, 29);
  169.             this.Label1.Name = "Label1";
  170.             this.Label1.Size = new System.Drawing.Size(104, 15);
  171.             this.Label1.TabIndex = 6;
  172.             this.Label1.Text = "Type:";
  173.             // 
  174.             // RefreshBtn
  175.             // 
  176.             this.RefreshBtn.Location = new System.Drawing.Point(352, 16);
  177.             this.RefreshBtn.Name = "RefreshBtn";
  178.             this.RefreshBtn.Size = new System.Drawing.Size(105, 24);
  179.             this.RefreshBtn.TabIndex = 2;
  180.             this.RefreshBtn.Text = "Refresh";
  181.             this.RefreshBtn.Click += new System.EventHandler(this.RefreshBtn_Click);
  182.             // 
  183.             // EjectBtn
  184.             // 
  185.             this.EjectBtn.Location = new System.Drawing.Point(352, 48);
  186.             this.EjectBtn.Name = "EjectBtn";
  187.             this.EjectBtn.Size = new System.Drawing.Size(105, 24);
  188.             this.EjectBtn.TabIndex = 4;
  189.             this.EjectBtn.Text = "Eject";
  190.             this.EjectBtn.Click += new System.EventHandler(this.EjectBtn_Click);
  191.             // 
  192.             // OKBtn
  193.             // 
  194.             this.OKBtn.Location = new System.Drawing.Point(352, 104);
  195.             this.OKBtn.Name = "OKBtn";
  196.             this.OKBtn.Size = new System.Drawing.Size(105, 24);
  197.             this.OKBtn.TabIndex = 5;
  198.             this.OKBtn.Text = "OK";
  199.             this.OKBtn.Click += new System.EventHandler(this.OKBtn_Click);
  200.             // 
  201.             // frmDiskInfo
  202.             // 
  203.             this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
  204.             this.ClientSize = new System.Drawing.Size(464, 141);
  205.             this.Controls.AddRange(new System.Windows.Forms.Control[] {
  206.                                                                           this.OKBtn,
  207.                                                                           this.EjectBtn,
  208.                                                                           this.RefreshBtn,
  209.                                                                           this.GroupBox1});
  210.             this.ImeMode = System.Windows.Forms.ImeMode.Disable;
  211.             this.Name = "frmDiskInfo";
  212.             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
  213.             this.Text = "frmDiskInfo";
  214.             this.Load += new System.EventHandler(this.frmDiskInfo_Load);
  215.             this.GroupBox1.ResumeLayout(false);
  216.             this.ResumeLayout(false);
  217.  
  218.         }
  219.         #endregion
  220.  
  221.         private void frmDiskInfo_Load(object sender, System.EventArgs e)
  222.         {
  223.             frm = (Form1)this.Owner;
  224.             RefreshFormData();
  225.         }
  226.  
  227.         private void RefreshFormData()
  228.         {
  229.             Int32 w = 0;
  230.             frm.RefreshDiskInfo();
  231.  
  232.             w = (frm.DataCDWriter1.cdUsedSpace / 1024) / 1024;
  233.             cdUsedSpaceLbl.Text = w.ToString() + " MB";
  234.  
  235.  
  236.  
  237.             w = (frm.DataCDWriter1.GetDataVolumeBurnSize() / 1024) / 1024;
  238.             cdEstUsedSpaceLbl.Text = w.ToString() + " MB";
  239.  
  240.             switch(frm.DataCDWriter1.cdType)
  241.             {
  242.                 case NCTDISCWRITERLib.CD_TYPE.WRITEONCE:
  243.                 {
  244.                     cdTypeLbl.Text = "CD-R, CD-ROM";
  245.                     EjectBtn.Enabled = true;
  246.                     break;
  247.                 }
  248.                 case NCTDISCWRITERLib.CD_TYPE.ERASABLE:
  249.                 {
  250.                     cdTypeLbl.Text = "CD-RW";
  251.                     EjectBtn.Enabled = true;
  252.                     break;
  253.                 }
  254.                 case NCTDISCWRITERLib.CD_TYPE.RANDOMACCESS:
  255.                 {
  256.                     cdTypeLbl.Text = "DVD-RAM";
  257.                     EjectBtn.Enabled = true;
  258.                     break;
  259.                 }
  260.                 case NCTDISCWRITERLib.CD_TYPE.NODISC:
  261.                 {
  262.                     cdTypeLbl.Text = "No Disc";
  263.                     EjectBtn.Enabled = false;
  264.                     cdUsedSpaceLbl.Text = "0";
  265.                     break;
  266.                 }
  267.             }
  268.  
  269.             switch(frm.DataCDWriter1.cdStatus)
  270.             {
  271.                 case NCTDISCWRITERLib.CD_STATUS.BLANK:
  272.                 {
  273.                     cdStatusLbl.Text = "Blank";
  274.                     cdUsedSpaceLbl.Text = "0";
  275.                     break;
  276.                 }
  277.                 case NCTDISCWRITERLib.CD_STATUS.WRITEBLE:
  278.                 {
  279.                     cdStatusLbl.Text = "Open";
  280.                     break;
  281.                 }
  282.                 case NCTDISCWRITERLib.CD_STATUS.NOTWRITEBLE:
  283.                 {
  284.                     cdStatusLbl.Text = "Closed";
  285.                     break;
  286.                 }
  287.                     
  288.                 case NCTDISCWRITERLib.CD_STATUS.UNRECOGNIZED:
  289.                 {
  290.                     cdStatusLbl.Text = "Unknown";
  291.                     cdUsedSpaceLbl.Text = "0";
  292.                     break;
  293.                 }
  294.             }
  295.         }
  296.  
  297.         private void RefreshBtn_Click(object sender, System.EventArgs e)
  298.         {
  299.             this.RefreshFormData();
  300.         }
  301.  
  302.         private void EjectBtn_Click(object sender, System.EventArgs e)
  303.         {
  304.             frm.DataCDWriter1.Eject();
  305.             frm.RefreshDiskInfo();
  306.             this.RefreshFormData();
  307.         }
  308.  
  309.         private void OKBtn_Click(object sender, System.EventArgs e)
  310.         {
  311.             this.Hide();
  312.         }
  313.     }
  314. }
  315.